package com.sinosoft.hydra.um.services.component.dataCollect.parsers;

import cn.com.sinux.spring.utils.DateUtils;
import com.sinosoft.hydra.logging.LogModules;
import com.sinosoft.hydra.um.constant.BaseConstant;
import org.slf4j.LoggerFactory;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2016/8/16.
 */
public class YgchParser extends Parser {


    public List<String> getTitles() {
        return Arrays.asList("时间", "Ni（微米）", "Mo（微米）");
    }

    public List<String> parse(List<String> cells, Date begin, Date end){
        List<String> list = new ArrayList<String>();
        Date date;
        String time = cells.get(0) + " " +cells.get(1);
        try {
            date = DateUtils.parseDate(time, BaseConstant.timePatterns);
        } catch (ParseException e) {
            LoggerFactory.getLogger(LogModules.STD_LOGGER).error("日期格式转换失败{}", e.getMessage());
            return null;
        }
        if (begin != null && date.before(begin) || (end != null && date.after(end))) {
            return null;
        }
        list.add(time);
        list.addAll(cells.subList(2, cells.size()));
        return list;
    }
}
